<script>
	import {WebSocketClient} from "@/util/WebSocketClient";
	import http from "@/util/http";
	export default {
		data() {
			return {
				isInit: true,
				isAppHide: false,
			}
		},
		onLaunch: function() {
		},
		onShow: function() {
      // #ifdef MP
      this.updateMP()
      // #endif
			// console.log('App onShow=')
			var pages = getCurrentPages()
			// console.log('pages=', pages,this.isInit)
			//第一次进入小程序
			if (this.isInit || !pages.length) {
				this.isInit = false
			}else {
				//页面最小化返回，进行重连操作
				// this.$tool.testWebsocket()
			}
		},
		onHide: function() {
			console.log('App Hide')
			// this.$tool.closeWebsocket()
		},
    methods: {
      // 更新小程序
      updateMP() {
        const updateManager = uni.getUpdateManager();

        updateManager.onCheckForUpdate(function (res) {
          // 请求完新版本信息的回调
          // console.log(res.hasUpdate);
        });

        updateManager.onUpdateReady(function (res) {
          uni.showModal({
            title: '更新提示',
            content: '新版本已经准备好，是否重启应用？',
            success(res) {
              if (res.confirm) {
                // 新的版本已经下载好，调用 applyUpdate 应用新版本并重启
                updateManager.applyUpdate();
              }
            }
          });
        });

        updateManager.onUpdateFailed(function (res) {
          // 新的版本下载失败
        });
      }
    },
		globalData: {
			schoolCode:'',
			schoolName:'',
		}
	}
</script>

<style lang="scss">
$gd_unit:rpx;
$gd_is-uni-app:true;
/*每个页面公共css */
@import "@/uni_modules/uview-plus/index.scss";
@import "@/plugin/main.css";
@import "@/plugin/icon.css";
@import "@/plugin/animation.css";
@import "gd-lib/atomic-classes/index.scss";

.d_flex_c{display: flex;justify-content: center;align-items: center;}
.d_flex_b{display: flex;justify-content: space-between;align-items: center;}
.d_flex{display: flex;}
.flex1{flex: 1;}
.flex2{flex: 2;}
.f_w{flex-wrap: wrap;}
.f_dc{flex-direction: column;}
.a_c{align-items: center;}
.j_c{justify-content: center;}
.j_b{justify-content: space-between;}
.j_a{justify-content: space-around;}
.flex_warp{flex-wrap: wrap;}
.t_c{text-align: center;}
.f-blod{font-weight: bold;}
.red{color: #FF7474;}
.green{color: #20CE7C;}
.theme{color: #5480F8;}
page{
	color: #333;
}

@for $v from 0 through 10 {
  .flex-#{$v} {
    flex: #{$v};
  }
}

@for $v from 0 through 100 {
  .text-#{$v} {
    font-size: #{$v}#{$gd_unit};
  }
  .p-#{$v} {
    padding: #{$v}#{$gd_unit};
  }
  .m-#{$v} {
    margin: #{$v}#{$gd_unit};
  }
  
}

@for $v from 0 through 50 {
  .rounded-#{$v} {
    border-radius: #{$v}#{$gd_unit};
  }
  .ml-#{$v} {
    padding-left: #{$v}#{$gd_unit};
  }
	.mr-#{$v} {
    padding-right: #{$v}#{$gd_unit};
  }
	.mt-#{$v} {
    margin-top: #{$v}#{$gd_unit};
  }
	.mb-#{$v} {
    margin-bottom: #{$v}#{$gd_unit};
  }
	.pl-#{$v} {
    padding-left: #{$v}#{$gd_unit};
  }
	.pr-#{$v} {
    padding-right: #{$v}#{$gd_unit};
  }
	.pt-#{$v} {
    padding-top: #{$v}#{$gd_unit};
  }
	.pb-#{$v} {
    padding-bottom: #{$v}#{$gd_unit};
  }
	.px-#{$v} {
    padding-left: #{$v}#{$gd_unit};
    padding-right: #{$v}#{$gd_unit};
  }
	.py-#{$v} {
    padding-top: #{$v}#{$gd_unit};
    padding-bottom: #{$v}#{$gd_unit};
  }
}
</style>
